﻿/// <reference path="../Turbo/Turbo.js" />
/// <reference path="../General/Json.js" />
/// <reference path="../Data/Data.js" />

$RepeaterSortField = TA.Turbo.Controls.RepeaterSortField = function RepeaterSortField()
{
}
$RepeaterSortField.Inherit(EventSender);
$RepeaterSortField.Inherit(BaseJsonSerializable);
$RepeaterSortField.Inherit(BaseJsonDeserializable);

$RepeaterSortField.prototype._field = null;
$RepeaterSortField.prototype._direction = $SortDirection.Ascending;
$RepeaterSortField.prototype._compareHandler = null;

$RepeaterSortField.prototype.get_Field = function get_Field()
{
	return this._field;
}
$RepeaterSortField.prototype.get_Direction = function get_Direction()
{
	return this._direction;
}
$RepeaterSortField.prototype.get_CompareHandler = function get_CompareHandler()
{
	return this._compareHandler;
}

$RepeaterSortField.prototype.SerializeContents = function SerializeContents(jw)
{
	jw.Property("F", this.get_Field());

	jw.Property("D", this.get_Direction());

	jw.Property("C", this.get_CompareHandler());
}
$RepeaterSortField.prototype.DeserializeContent = function DeserializeContent(prShortName, value)
{
	switch (prShortName)
	{
		case "F":
			this._field = value;
			break;
		case "D":
			this._direction = value;
			break;
		case "C":
			if (this._compareHandler != null)
				this.RemoveEvent("Compare", this._compareHandler);

			this._compareHandler = value;

			this.AddEvent("Compare", this._compareHandler);
			break;
	}
}
